import DrawUtil from '@/tchart/generalPurpose/drawUtil'
import { TCHART_CONFIG, P_CONST, INIT_Y } from '@/tchart/generalPurpose/tchart.config'
import * as zrender from 'zrender'
let INITY = INIT_Y
const periphery = {
  /**
     * 标题与患者基本信息
     * data:{
     *     hosName:'武定县妇幼保健院',
     *     deptName:'新生儿科',
     *     admissionDate:'2020-07-27',
     *     name:'张三',
     *     sex:'男',
     *     age:'0岁10月20天',
     *     bedNo:'15',
     *     visitNo:'20200001016',
     * }
     * @param data
     * @param zr
     * @returns {number}
     */
  tbHeader: function (data, zr) {
    //标题x坐标=(天数【7】*时段数【6】*最小单元宽度【15】+左侧标签宽度)/居中【2】
    // eslint-disable-next-line camelcase
    const title_x = (TCHART_CONFIG.DAYS * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH + P_CONST.LABEL_WIDTH) / 2
    //分5格
    // eslint-disable-next-line camelcase
    const header_x = (TCHART_CONFIG.DAYS * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH + P_CONST.LABEL_WIDTH) / 5
    /*表头区域*/
    // eslint-disable-next-line no-undef
    zr.add(DrawUtil.drawText({
      x: title_x-25,
      y: INITY,
      text: data.hosName,
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: 20,
      textAlign: 'center'
    }, 'T', '#000'))
    INITY += P_CONST.LABEL_HEIGHT + 15 //副标题
    zr.add(DrawUtil.drawText({
      x: title_x-30,
      y: INITY-10,
      text: '体 温 单',
      fontFamily: '仿宋',
      fontWeight: '800',
      textAlign: 'center',
      fontSize: '1.5rem'

    }, 'T', '#000'))

    /**************************第2行*************************/
    zr.add(DrawUtil.drawText({
      x: 0,
      y: INITY,
      text: '监室：',
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      x: 40,
      y: INITY,
      text: data.deptName,
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x * 4,
      y: INITY,
      text: '入所日期：',
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x * 4 + 70,
      y: INITY,
      fontFamily: '仿宋',
      fontWeight: '800',
      text: data.admissionDate,
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    /**************************第3行*************************/
    INITY += P_CONST.LABEL_HEIGHT
    zr.add(DrawUtil.drawText({
      x: 0,
      y: INITY,
      text: '姓名：',
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      x: 40,
      y: INITY,
      text: data.name,
      hint: data.name,
      fontFamily: '仿宋',
      fontWeight: '800',
      truncate: {
        outerWidth: 130
      },
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      x: header_x,
      y: INITY,
      text: '性别：',
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x + 40,
      y: INITY,
      text: data.sex,
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x * 2,
      y: INITY,
      text: '年龄：',
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x * 2 + 40,
      y: INITY,
      text: data.age,
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    // zr.add(DrawUtil.drawText({
    //   // eslint-disable-next-line camelcase
    //   x: header_x * 3,
    //   y: INITY,
    //   text: '床号：',
    //   fontFamily: '仿宋',
    //   fontWeight: '800',
    //   fontSize: P_CONST.fontSize,
    //   textAlign: 'left'
    // }, 'T', '#000'))
    // zr.add(DrawUtil.drawText({
    //   // eslint-disable-next-line camelcase
    //   x: header_x * 3 + 40,
    //   y: INITY,
    //   text: data.bedNo,
    //   fontFamily: '仿宋',
    //   fontWeight: '800',
    //   fontSize: P_CONST.fontSize,
    //   textAlign: 'left'
    // }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x * 4,
      y: INITY,
      text: '在所编号：',
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: header_x * 4 + 60,
      y: INITY,
      text: data.visitNo,
      fontFamily: '仿宋',
      fontWeight: '800',
      fontSize: P_CONST.fontSize,
      textAlign: 'left'
    }, 'T', '#000'))
    INITY += 20
    return INITY
    /*表头区域 end*/
  },
  //上表格
  topTable: function (data, zr, param) {
    const labels = ['日       期', '住 院 天 数', '手术或产后天数', '时       间'],
      LINE = 5,
      APM = ['早上', '中午', '晚上'],
      LABEL_COLUMN = 1
    //4行1列table
    // eslint-disable-next-line camelcase
    const [label_height, label_width] = [P_CONST.TABLE_LINE_HEIGHT, P_CONST.LABEL_WIDTH]
    const labelTableGroup = new zrender.Group()
    for (let i = 0; i <= LINE; i++) {
      let lineTobj = { stroke: '#000', lineWidth: 1 }
      if (i === 4) {
        lineTobj = { stroke: '#000', opacity: 1, y1: 0 }
      }
      const lineT = new zrender.Line({
        shape: {
          x1: 0,
          // eslint-disable-next-line camelcase
          y1: label_height * i,
          // eslint-disable-next-line camelcase
          x2: label_width * LABEL_COLUMN,
          // eslint-disable-next-line camelcase
          y2: label_height * i
        },
        style: {
          stroke: lineTobj.stroke,
          lineWidth: lineTobj.lineWidth
        }
      })
      labelTableGroup.add(lineT)
    }
    for (let i = 0; i <= LABEL_COLUMN; i++) {
      const lineLobj = { stroke: '#000', lineWidth: 1, opacity: 1 }

      const lineL = new zrender.Line({
        shape: {
          // eslint-disable-next-line camelcase
          x1: label_width * i,
          y1: 0,
          // eslint-disable-next-line camelcase
          x2: label_width * i,
          // eslint-disable-next-line camelcase
          y2: label_height * LINE
        },
        style: {
          stroke: lineLobj.stroke,
          lineWidth: lineLobj.lineWidth,
          opacity: lineLobj.opacity
        }
      })

      labelTableGroup.add(lineL)
    }
    labelTableGroup.attr('position', [0, INITY])
    zr.add(labelTableGroup) //左上区域

    // eslint-disable-next-line camelcase
    const [data_height, data_width] = [P_CONST.TABLE_LINE_HEIGHT, TCHART_CONFIG.INIT_WIDTH]
    const dataTableGroup = new zrender.Group()
    //横向Line
    const DATA_COLUMN = TCHART_CONFIG.DAYS * TCHART_CONFIG.HOUR

    // eslint-disable-next-line camelcase
    const y_min_unit = TCHART_CONFIG.Y_MIN_UNIT //Y轴小单位个数
    for (let i = 0; i <= LINE; i++) {
      let lineTobj = { stroke: '#000', lineWidth: 1 }
      // eslint-disable-next-line camelcase
      if (i % y_min_unit === 0 && i !== 0 && i !== LINE) {
        lineTobj = { stroke: '#000', lineWidth: 2.5 }
      }
      const lineT = new zrender.Line({
        shape: {
          x1: 0,
          // eslint-disable-next-line camelcase
          y1: data_height * i,
          // eslint-disable-next-line camelcase
          x2: data_width * DATA_COLUMN,
          // eslint-disable-next-line camelcase
          y2: data_height * i
        },
        style: {
          stroke: lineTobj.stroke,
          lineWidth: lineTobj.lineWidth
        }
      })
      dataTableGroup.add(lineT)
    }
    //纵向Line
    const hour = TCHART_CONFIG.HOUR //时段
    for (let i = 0; i <= DATA_COLUMN; i++) {
      const nub = 2
      let lineLobj = { stroke: '#33CCFF', lineWidth: 1, opacity: 1, y1: P_CONST.TABLE_LINE_HEIGHT * 4 }
      if (i % nub === 0) {
        lineLobj = { stroke: '#000', lineWidth: 1, opacity: 1, y1: P_CONST.TABLE_LINE_HEIGHT * 3 }
      }
      if (i === 0 || i === DATA_COLUMN) {
        lineLobj = { stroke: '#000', lineWidth: 1, opacity: 1, y1: 0 }
      } else if (i % hour === 0) {
        lineLobj = { stroke: '#FF0000', lineWidth: 2.5, opacity: 1, y1: 0 }
      }
      const lineL = new zrender.Line({
        shape: {
          // eslint-disable-next-line camelcase
          x1: data_width * i,
          y1: lineLobj.y1,
          // eslint-disable-next-line camelcase
          x2: data_width * i,
          // eslint-disable-next-line camelcase
          y2: data_height * LINE
        },
        style: {
          stroke: lineLobj.stroke,
          lineWidth: lineLobj.lineWidth,
          opacity: lineLobj.opacity
        }
      })
      dataTableGroup.add(lineL)
    }
    // eslint-disable-next-line camelcase
    dataTableGroup.attr('position', [label_width, INITY])
    zr.add(dataTableGroup)//右上区域
    console.log('aaaaa')
    for (let i = 0; i < labels.length; i++) {
      const d = labels[i]
      let y = INITY + P_CONST.TABLE_LINE_HEIGHT * i + 6
      if (i === 3) {
        y = INITY + P_CONST.TABLE_LINE_HEIGHT * i + P_CONST.TABLE_LINE_HEIGHT - 6
      }
      zr.add(DrawUtil.drawText({
        // eslint-disable-next-line camelcase
        x: label_width / 6,
        y: y,
        text: d,
        fontFamily: '仿宋',
        fontWeight: '800',
        fontSize: 14,
        textAlign: 'center'
      }, 'T', '#000'))
    }

    /****************** 日期 赋值*****************/
    for (let i = 0; i < data.days.length; i++) {
      const d = data.days[i]
      if(i==0){
        zr.add(DrawUtil.drawText({
          x: P_CONST.LABEL_WIDTH + i * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                      TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / 10,
          y: INITY + 6,
          text: d,
          fontSize: P_CONST.fontSize,
          textAlign: 'center'
        }, 'T', '#000'))
      }else if(i==data.days.length-1){
        zr.add(DrawUtil.drawText({
          x: P_CONST.LABEL_WIDTH + i * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                      TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / 3,
          y: INITY + 6,
          text: d,
          fontSize: P_CONST.fontSize,
          textAlign: 'center'
        }, 'T', '#000'))
      } else {
        zr.add(DrawUtil.drawText({
          x: P_CONST.LABEL_WIDTH + i * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                      TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / 2,
          y: INITY + 6,
          text: d,
          fontSize: P_CONST.fontSize,
          textAlign: 'center'
        }, 'T', '#000'))
      }
     
    }

    /****************** 住院天数 赋值*****************/
    for (let i = 0; i < data.inHosDays.length; i++) {
      const d = data.inHosDays[i]
      zr.add(DrawUtil.drawText({
        x: P_CONST.LABEL_WIDTH + i * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                    TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / 2,
        y: INITY + P_CONST.TABLE_LINE_HEIGHT + 6,
        text: d,
        fontSize: P_CONST.fontSize,
        textAlign: 'center'
      }, 'T', '#000'))
    }
    /****************** 术后天数 赋值*****************/
    for (let i = 0; i < data.operationDays.length; i++) {
      const d = data.operationDays[i]
      zr.add(DrawUtil.drawText({
        x: P_CONST.LABEL_WIDTH + i * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                    TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / 2,
        y: INITY + P_CONST.TABLE_LINE_HEIGHT * 2 + 6,
        text: d,
        fontSize: P_CONST.fontSize,
        textAlign: 'center'
      }, 'T', '#FF0000'))
    }
    /****************** 上下午 赋值*****************/
    for (let i = 0; i < APM.length * 7; i++) {
      const x = P_CONST.LABEL_WIDTH + (TCHART_CONFIG.INIT_WIDTH * 2 / 30) + (TCHART_CONFIG.INIT_WIDTH * 2 * i);
      let t = APM[2]; // 默认值为 "晚上"
      if (i % 3 === 0) {
        t = APM[0]; // "早上"
      } else if (i % 3 === 1) {
        t = APM[1]; // "中午"
      }
      zr.add(DrawUtil.drawText({
        x: x,
        y: INITY + P_CONST.TABLE_LINE_HEIGHT * 3 + 3,
        text: t,
        fontSize: P_CONST.fontSize,
        fontFamily: P_CONST.fontFamily,
        fontWeight: 800,
        textAlign: 'center'
      }, 'T', '#000'));
    }
    /****************** 时间 赋值*****************/
    for (let i = 0; i < TCHART_CONFIG.DAYS; i++) {
      for (let j = 0; j < data.hours.length; j++) {
        const d = data.hours[j]
        let color = '#000'
        if (j === 0 || j === 1 || j === 5) {
          color = '#FF0000'
        }
        zr.add(DrawUtil.drawText({
          x: P_CONST.LABEL_WIDTH + i * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                        j * TCHART_CONFIG.INIT_WIDTH + TCHART_CONFIG.INIT_WIDTH / 2-6,
          y: INITY + P_CONST.TABLE_LINE_HEIGHT * 4 + 6,
          text: d,
          fontSize: 11,
          textAlign: 'center'
        }, 'T', color))
      }
    }

    INITY = INITY + P_CONST.TABLE_LINE_HEIGHT * 5
    return INITY
  },
  //左表格
  leftTable: function (data, zr, param) {
    // eslint-disable-next-line camelcase
    const left_data = {
        pulse: [180, 160, 140, 120, 100, 80, 60, 40],
        breathe: [42, 41, 40, 39, 38, 37, 36, 35]
      },
      LINE = 1,
      LABEL_COLUMN = 2
    // eslint-disable-next-line camelcase
    const [label_height, label_width] = [TCHART_CONFIG.Y_MIN_UNIT * TCHART_CONFIG.Y_MAX_UNIT * TCHART_CONFIG.INIT_HEIGHT - TCHART_CONFIG.INIT_HEIGHT * 3, P_CONST.LABEL_WIDTH / 2]
    const labelTableGroup = new zrender.Group()
    for (let i = 0; i <= LINE; i++) {
      const lineTobj = { stroke: '#000', lineWidth: 1 }
      const lineT = new zrender.Line({
        shape: {
          x1: 0,
          // eslint-disable-next-line camelcase
          y1: label_height * i,
          // eslint-disable-next-line camelcase
          x2: label_width * LABEL_COLUMN,
          // eslint-disable-next-line camelcase
          y2: label_height * i
        },
        style: {
          stroke: lineTobj.stroke,
          lineWidth: lineTobj.lineWidth
        }
      })
      labelTableGroup.add(lineT)
    }
    for (let i = 0; i <= LABEL_COLUMN; i++) {
      const lineLobj = { stroke: '#000', lineWidth: 1, opacity: 1 }

      const lineL = new zrender.Line({
        shape: {
          // eslint-disable-next-line camelcase
          x1: label_width * i,
          y1: 0,
          // eslint-disable-next-line camelcase
          x2: label_width * i,
          // eslint-disable-next-line camelcase
          y2: label_height * LINE
        },
        style: {
          stroke: lineLobj.stroke,
          lineWidth: lineLobj.lineWidth,
          opacity: lineLobj.opacity
        }
      })

      labelTableGroup.add(lineL)
    }
    labelTableGroup.attr('position', [0, INITY])
    zr.add(labelTableGroup)
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: label_width / 6,
      y: INITY + 8,
      text: '脉搏',
      fontSize: P_CONST.fontSize,
      fontFamily: P_CONST.fontFamily,
      fontWeight: 800,
      textAlign: 'center'
    }, 'T', '#FF0000'))

    for (let i = 0; i < left_data.pulse.length; i++) {
      const d = left_data.pulse[i]
      zr.add(DrawUtil.drawText({
        // eslint-disable-next-line camelcase
        x: label_width / 6,
        y: INITY + (TCHART_CONFIG.INIT_HEIGHT * 2) + (TCHART_CONFIG.INIT_HEIGHT * 5 * i),
        text: d,
        fontSize: P_CONST.fontSize,
        textAlign: 'center'
      }, 'T', '#FF0000'))
    }
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: label_width / 6 + label_width,
      y: INITY + 8,
      text: '体温',
      fontSize: P_CONST.fontSize,
      fontFamily: P_CONST.fontFamily,
      fontWeight: 800,
      textAlign: 'center'
    }, 'T', '#0000FF'))

    for (let i = 0; i < left_data.breathe.length; i++) {
      const d = left_data.breathe[i]
      zr.add(DrawUtil.drawText({
        // eslint-disable-next-line camelcase
        x: label_width / 6 + label_width,
        y: INITY + (TCHART_CONFIG.INIT_HEIGHT * 2) + (TCHART_CONFIG.INIT_HEIGHT * 5 * i),
        text: d + '℃',
        fontSize: P_CONST.fontSize,
        textAlign: 'center'
      }, 'T', '#0000FF'))
    }
    INITY += TCHART_CONFIG.Y_MIN_UNIT * (TCHART_CONFIG.Y_MAX_UNIT - 1) * TCHART_CONFIG.INIT_HEIGHT + TCHART_CONFIG.INIT_HEIGHT * 2
    return INITY
  },
  //下表格
  bottomTable: function (data, zr, param) {
    console.log(data, '下表格')
    // eslint-disable-next-line camelcase
    let breathe_falg = true
    // eslint-disable-next-line camelcase
    let pain_level_falg = true
    // eslint-disable-next-line camelcase
    const [label_height, label_width] = [P_CONST.TABLE_LINE_HEIGHT, P_CONST.LABEL_WIDTH],
      LINE = 12, //辅助护理行
      LABEL_COLUMN = 1
    const labelTableGroup = new zrender.Group()
    for (let i = 0; i <= LINE; i++) {
      const lineTobj = { stroke: '#000', lineWidth: 1 }
      const lineT = new zrender.Line({
        shape: {
          x1: 0,
          // eslint-disable-next-line camelcase
          y1: label_height * i,
          // eslint-disable-next-line camelcase
          x2: label_width * LABEL_COLUMN,
          // eslint-disable-next-line camelcase
          y2: label_height * i
        },
        style: {
          stroke: lineTobj.stroke,
          lineWidth: lineTobj.lineWidth
        }
      })
      labelTableGroup.add(lineT)
    }
    for (let i = 0; i <= LABEL_COLUMN; i++) {
      const lineLobj = { stroke: '#000', lineWidth: 1, opacity: 1 }

      const lineL = new zrender.Line({
        shape: {
          // eslint-disable-next-line camelcase
          x1: label_width * i,
          y1: 0,
          // eslint-disable-next-line camelcase
          x2: label_width * i,
          // eslint-disable-next-line camelcase
          y2: label_height * LINE
        },
        style: {
          stroke: lineLobj.stroke,
          lineWidth: lineLobj.lineWidth,
          opacity: lineLobj.opacity
        }
      })

      labelTableGroup.add(lineL)
    }
    labelTableGroup.attr('position', [0, INITY])

    zr.add(labelTableGroup)

    // eslint-disable-next-line camelcase
    const [data_height, data_width] = [P_CONST.TABLE_LINE_HEIGHT, TCHART_CONFIG.INIT_WIDTH]
    const dataTableGroup = new zrender.Group()
    //横向Line
    const DATA_COLUMN = TCHART_CONFIG.DAYS * TCHART_CONFIG.HOUR

    for (let i = 0; i <= LINE; i++) {
      const lineTobj = { stroke: '#000', lineWidth: 1 }
      const lineT = new zrender.Line({
        shape: {
          x1: 0,
          // eslint-disable-next-line camelcase
          y1: data_height * i,
          // eslint-disable-next-line camelcase
          x2: data_width * DATA_COLUMN,
          // eslint-disable-next-line camelcase
          y2: data_height * i
        },
        style: {
          stroke: lineTobj.stroke,
          lineWidth: lineTobj.lineWidth
        }
      })
      dataTableGroup.add(lineT)
    }
    //纵向Line
    // eslint-disable-next-line camelcase
    const data_hour = TCHART_CONFIG.HOUR //时段
    for (let i = 0; i <= DATA_COLUMN; i++) {
      // eslint-disable-next-line camelcase
      let lineLobj = { stroke: '#33CCFF', lineWidth: 1, opacity: 1, y1: 0, y2: data_height * 2 }
      if (i === 0 || i === DATA_COLUMN) {
        // eslint-disable-next-line camelcase
        lineLobj = { stroke: '#000', lineWidth: 1, opacity: 1, y1: 0, y2: data_height * LINE }
        // eslint-disable-next-line camelcase
      } else if (i % data_hour === 0) {
        // eslint-disable-next-line camelcase
        lineLobj = { stroke: '#FF0000', lineWidth: 2.5, opacity: 1, y1: 0, y2: data_height * LINE }
      }

      const lineL = new zrender.Line({
        shape: {
          // eslint-disable-next-line camelcase
          x1: data_width * i,
          y1: lineLobj.y1,
          // eslint-disable-next-line camelcase
          x2: data_width * i,
          y2: lineLobj.y2
        },
        style: {
          stroke: lineLobj.stroke,
          lineWidth: lineLobj.lineWidth,
          opacity: lineLobj.opacity
        }
      })

      dataTableGroup.add(lineL)
    }
    dataTableGroup.attr('position', [P_CONST.LABEL_WIDTH, INITY])
    zr.add(dataTableGroup)
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: label_width / 6,
      y: INITY + 4,
      text: '呼吸',
      fontSize: P_CONST.fontSize,
      fontFamily: P_CONST.fontFamily,
      fontWeight: '800',
      textAlign: 'center'
    }, 'T', '#000'))
    zr.add(DrawUtil.drawText({
      // eslint-disable-next-line camelcase
      x: label_width / 6,
      y: INITY + P_CONST.TABLE_LINE_HEIGHT + 4,
      text: '疼痛程度',
      fontSize: P_CONST.fontSize,
      fontFamily: P_CONST.fontFamily,
      fontWeight: '800',
      textAlign: 'center'
    }, 'T', '#000'))
    for (let i = 0; i < data.alyKey.length; i++) {
      const lable = data.alyKey[i]
      zr.add(DrawUtil.drawText({
        // eslint-disable-next-line camelcase
        x: label_width / 6,
        y: INITY + P_CONST.TABLE_LINE_HEIGHT + P_CONST.TABLE_LINE_HEIGHT * (i + 1) + 3.5,
        text: lable,
        fontSize: P_CONST.fontSize,
        textAlign: 'center'
      }, 'T', '#000'))
    }
    INITY += P_CONST.TABLE_LINE_HEIGHT
    /************************呼吸 疼痛&辅助护理 数据处理*********************/
    for (let i = 0; i < data.tbData.length; i++) {
      const day = data.tbData[i]//获取day数据
      // eslint-disable-next-line camelcase
      let day_sub = -1
      for (let x = 0; x < data.days.length; x++) {
        const d = data.days[x]
        if (d === day.datetime) {
          // eslint-disable-next-line camelcase
          day_sub = x
        }
      }
      // eslint-disable-next-line camelcase
      if (day_sub === -1) {
        continue
      }
      /************************呼吸 数据处理*********************/
      for (let j = 0; j < day.hours.length; j++) {
        const h = day.hours[j]
        // eslint-disable-next-line camelcase
        const _x = P_CONST.LABEL_WIDTH + day_sub * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                    j * TCHART_CONFIG.INIT_WIDTH + TCHART_CONFIG.INIT_WIDTH / 6
        let _y = INITY - P_CONST.TABLE_LINE_HEIGHT + 5
        if (h.breatheType || h.breathe) {
          // eslint-disable-next-line camelcase
          if (breathe_falg) {
            _y = INITY - P_CONST.TABLE_LINE_HEIGHT + 5
            // eslint-disable-next-line camelcase
            breathe_falg = false
          } else {
            _y = INITY - P_CONST.TABLE_LINE_HEIGHT + 5
            // eslint-disable-next-line camelcase
            breathe_falg = true
          }
        }
        if (h.breatheType) {
          zr.add(DrawUtil.drawXCircle({ x: _x, y: _y + 2, text: 'R', txt: 'R' }, '#000'))
        } else {
          zr.add(DrawUtil.drawText({
            x: _x-2,
            y: _y,
            text: h.breathe,
            fontSize: 11,
            textAlign: 'center'
          }, 'T', '#000'))
        }
      }
      /************************疼痛 数据处理*********************/
      for (let j = 0; j < day.hours.length; j++) {
        const h = day.hours[j]
        // eslint-disable-next-line camelcase
        const _x = P_CONST.LABEL_WIDTH + day_sub * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                    j * TCHART_CONFIG.INIT_WIDTH + TCHART_CONFIG.INIT_WIDTH / 6
        let _y = INITY + 2
        if (h.painLevel) {
          // eslint-disable-next-line camelcase
          if (pain_level_falg) {
            _y = INITY + 2
            // eslint-disable-next-line camelcase
            pain_level_falg = false
          } else {
            _y = INITY + 9
            // eslint-disable-next-line camelcase
            pain_level_falg = true
          }
        }
        zr.add(DrawUtil.drawText({
          x: _x,
          y: _y,
          text: h.painLevel,
          fontSize: 11,
          textAlign: 'center'
        }, 'T', '#000'))
      }
      /************************辅助护理数据处理*********************/
      //血压分割
      if (P_CONST.BLOODCOLNUM > 1) {
        console.log('11')
        // eslint-disable-next-line camelcase
        let aly_x = -1
        for (let k = 0; k < data.alyKey.length; k++) {
          const _key = data.alyKey[k]
          if (_key.slice(0, 2) === '血压') {
            // eslint-disable-next-line camelcase
            aly_x = k + 1
          }
        }
        var bloodColumnGroup = new zrender.Group()
        // eslint-disable-next-line camelcase
        const [blood_height, blood_width] = [P_CONST.TABLE_LINE_HEIGHT, TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR]
        // 竖线
        const lineLobj = {
          stroke: '#000',
          lineWidth: 1,
          opacity: 1,
          // eslint-disable-next-line camelcase
          y1: blood_height * (aly_x),
          // eslint-disable-next-line camelcase
          y2: blood_height * (aly_x + 1)
        }
        for (let i = 0; i < TCHART_CONFIG.DAYS; i++) {
          for (let j = 0; j < P_CONST.BLOODCOLNUM - 1; j++) {
            // eslint-disable-next-line camelcase
            const x = blood_width / P_CONST.BLOODCOLNUM
            const lineL = new zrender.Line({
              shape: {
                // eslint-disable-next-line camelcase
                x1: x + x * j + blood_width * i,
                y1: lineLobj.y1,
                // eslint-disable-next-line camelcase
                x2: x + x * j + blood_width * i,
                y2: lineLobj.y2
              },
              style: {
                stroke: lineLobj.stroke,
                lineWidth: lineLobj.lineWidth,
                opacity: lineLobj.opacity
              }
            })
            bloodColumnGroup.add(lineL)
          }
        }
        bloodColumnGroup.attr('position', [P_CONST.LABEL_WIDTH, INITY])
        zr.add(bloodColumnGroup)
      }
      //由于血压比较特殊 有可能会显示多个
      for (let x = 0; x < day.auxiliary.length; x++) {
        const aly = day.auxiliary[x]
        // eslint-disable-next-line camelcase
        let aly_x = -1
        for (let k = 0; k < data.alyKey.length; k++) {
          const _key = data.alyKey[k]
          if (_key.indexOf('(') !== -1) {
            if (aly.key === _key.substring(0, _key.indexOf('('))) {
              // eslint-disable-next-line camelcase
              aly_x = k
            }
          } else {
            if (aly.key === _key) {
              // eslint-disable-next-line camelcase
              aly_x = k
            }
          }
        }
        // eslint-disable-next-line camelcase
        if (aly_x === -1) {
          continue
        }
        if (aly.key.slice(0, 2) === '血压') {
          for (let y = 0; y < P_CONST.BLOODCOLNUM; y++) {
            const _v = aly.value[y]
            const seg = TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / P_CONST.BLOODCOLNUM
            // eslint-disable-next-line camelcase
            const _x = P_CONST.LABEL_WIDTH + day_sub * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                            y * seg + TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / P_CONST.BLOODCOLNUM / 2
            // eslint-disable-next-line no-unused-vars
            let fontSize = 8
            if (P_CONST.BLOODCOLNUM === 1) {
              fontSize = P_CONST.fontSize
            }
            zr.add(DrawUtil.drawText({
              x: _x,
              // eslint-disable-next-line camelcase
              y: INITY + 4.5 + P_CONST.TABLE_LINE_HEIGHT * (aly_x + 1),
              text: _v,
              fontSize: 12,
              textAlign: 'center'
            }, 'T', '#000'))
          }
        } else {
          zr.add(DrawUtil.drawText({
            // eslint-disable-next-line camelcase
            x: P_CONST.LABEL_WIDTH + day_sub * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH +
                            TCHART_CONFIG.INIT_WIDTH * TCHART_CONFIG.HOUR / 2,
            // eslint-disable-next-line camelcase
            y: INITY + P_CONST.TABLE_LINE_HEIGHT * (aly_x + 1) + 4,
            text: aly.value,
            fontSize: P_CONST.fontSize,
            textAlign: 'center'
          }, 'T', '#000'))
        }
      }
    }

    /************************页码************/
    INITY = INITY + LINE * P_CONST.TABLE_LINE_HEIGHT + 6
    // eslint-disable-next-line camelcase
    const bottom_x = (TCHART_CONFIG.DAYS * TCHART_CONFIG.HOUR * TCHART_CONFIG.INIT_WIDTH + P_CONST.LABEL_WIDTH) / 2
    zr.add(DrawUtil.drawText({
      x: bottom_x-10,
      y: INITY,
      text: '第' + data.pageNo + '周',
      fontSize: P_CONST.fontSize,
      textAlign: 'center'
    }, 'T', '#000'))
    INITY = param.tb_height
    return INITY
  }
}
export default periphery
